# UNICODE IDENTIFIERS/OPERATORS
fun normalize(a) {
    var result = 0
    for i in a {
        result += i²
    }
    √(result)
}

# LAMBDAS
fun normalize(a) {
    √sum a.map(x => x²)
}

# VECTORIZATION SYNTAX
fun normalize(a) { √(a.²) }

# TYPE ANNOTATION
fun anyCommonElements(l: T, r: U) -> Bool where |T, U| <: Sequence {
    for a in l and b in r where a == b {
        return true
    }
    false
}

# MATCH EXPRESSION
fun fizzbuzz(i) {
    match (i mod 3, i mod 5) {
        (0, 0) => 'fizzbuzz',
        (0, _) => 'fizz',
        (_, 0) => 'buzz',
        (_, _) => string(i)
    }
}

# CONSTRUCTOR TYPES
type Person(name, age)
let ironman = Person('Tony Stark', 43)

# DESTRUCTURING
fun print({ name, age }) {
    print(name, age)
}
print(ironman)

# ALGEBRAIC DATA TYPES
type Traffic {
    Amber,
    Red,
    Green,
}

# REGEX LITERAL
fun wordcount(text) {
    let words = text.split(||[ \n\t\-.,:;]+||)
    var counts = {}
    for w in words {
        counts[w] = (counts[w] or 0) + 1
    }
    return counts
}
